<template>
  <div class="job-list">
    <Table
      ref="table"
      :searchData="searchData"
      :service="services.search"
      @selection-change="handleSelectionChange"
    >
      <template #tools>
        <div class="toolbar">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="small"
            @click="$router.push('/company/job-list/edit')"
            >新增岗位</el-button
          >
          <el-input
            class="search-input"
            size="small"
            placeholder="请输入岗位标签或岗位名称"
            v-model="searchData.keyword"
          >
            <el-button type="primary" slot="append" @click="search"
              >搜索</el-button
            >
          </el-input>
        </div>
      </template>
      <el-table-column prop="jobCode" :label="$t('job.jobCode')" />
      <el-table-column prop="publishTime" :label="$t('job.publishTime')" />
      <el-table-column prop="dueDate" :label="$t('job.dueDate')" />
      <el-table-column prop="jobTags" :label="$t('job.jobTags')" />
      <TableColumnEnum
        prop="jobType"
        :label="$t('job.jobType')"
        enumType="JOB_TYPE"
      />
      <el-table-column prop="jobName" :label="$t('job.jobName')" />
      <el-table-column prop="resumeNum" :label="$t('job.resumeNum')" />
      <TableColumnEnum
        prop="approvalStatus"
        :label="$t('field.approvalStatus')"
        enumType="APPROVAL_STATUS"
      />
      <TableColumnAction v-slot="{ scope }" width="260">
        <el-button
          type="primary"
          size="mini"
          round
          @click="$router.push('/company/job-list/post?id=' + scope.row.id)"
          >查看投递简历</el-button
        >
        <el-button
          type="primary"
          size="mini"
          round
          @click="$router.push('/company/job-list/edit?id=' + scope.row.id)"
          >编辑</el-button
        >
        <el-button
          type="danger"
          size="mini"
          round
          @click="handleRemove(scope.row)"
          >删除</el-button
        >
      </TableColumnAction>
    </Table>
  </div>
</template>

<script>
import { crudMixin } from 'mixins'
import { Table, TableColumnEnum, TableColumnAction } from 'components'
import { searchJob, removeJob } from 'services/company/job'
export default {
  name: 'JobList',
  components: {
    Table,
    TableColumnEnum,
    TableColumnAction
  },
  mixins: [crudMixin],
  data() {
    return {
      services: {
        search: searchJob,
        remove: removeJob
      }
    }
  },
  created() {
    const { companyId } = this.$route.query
    this.searchData.companyId = companyId
  }
}
</script>
